package com.fzb.forum4j.service.impl;

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.fzb.forum4j.dao.api.IBaseDao;
import com.fzb.forum4j.po.QueryMode;
import com.fzb.forum4j.service.api.IBaseService;
@Service("baseServiceImpl")

public class BaseServiceImpl<T> implements IBaseService<T> {

	public  Logger log=Logger.getLogger(getClass());
	
	
	@Resource(name="hibBaseImpl")
	private IBaseDao<T> ibd;
	
	@Override
	public Serializable addEntity(T t) {
		return getIbd().addEntity(t);
	}

	@Override
	public void reMoveEntity(T t) {
		getIbd().reMoveEntity(t);
	}

	@Override
	public void modifyEntity(T t) {
		getIbd().modifyEntity(t);
	}

	@Override
	public void getEntityByEid(QueryMode<T> qmd) {
		getIbd().getEntityByEid(qmd);
	}

	@Override
	public void getList(QueryMode<T> t) {

		getIbd().getList(t);
	}
	
	@SuppressWarnings("unchecked")
	private Class<T> getClazz() {
		return (Class<T>) ((ParameterizedType)getClass()
				.getGenericSuperclass())
				.getActualTypeArguments()[0];
	}

	public void setIbd(IBaseDao<T> ibd) {
		this.ibd = ibd;
	}

	public IBaseDao<T> getIbd() {
		return ibd;
	}

	@Override
	public void batchDelByIds(QueryMode<T> qmd) {
		ibd.batchDelByIds(qmd);
		
	}

}
